package com.example.blog.api;

import com.example.blog.dao.picdao;
import com.example.blog.pojo.picture;
import com.example.blog.until.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : LiuWenHao
 * @create 2023/2/26 11:20
 */
@ResponseBody
@Controller
public class img {
    int x;
    int result;
    @Autowired
    picdao pic;
    @Autowired
    Random random;
    @GetMapping (value="/api/pic")
    public picture hello() {
        List<picture> picdaos = pic.getUserList();
        x=picdaos.size();
        result= random.random(x);
        return picdaos.get(result);
    }

}
